package Duoxiancheng;
//守护线程
//setDaedom()守护方法
public class TestDaedom {

    //上帝
    public static class God implements Runnable{
        @Override
        public void run() {
            while (true) {
                System.out.println("上帝一直守护着你");
            }
        }
    }
    //普通人
    public static class You implements Runnable{

        @Override
        public void run() {
            for (int i = 0; i <= 100; i++) {
                System.out.println("你开心的活了"+i+"年");
            }
            System.out.println("Good Byte Life");
        }
    }

    public static void main(String[] args) {
        //激活上帝
        God god=new God();
        Thread thread=new Thread(god);
        thread.setDaemon(true);
        thread.start();
        //激活普通人
        You you=new You();
        new Thread(you).start();
    }
}
